package inherit;
class Animal {
    public String name;
    public int age;

    public void eat() {
        System.out.println(name + "正在吃饭！");
    }

    /*public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }*/
}
//一般情况 继承不要超过3层
class Dog extends Animal{
    public void barks() {
        System.out.println(name + "汪汪叫！"+"年龄:"+age);
    }

}
/*
    Cat为子类/派生类
    extends ：继承
    Animal为父类/基类/超类
    当子类继承父类后就会把所有的属性和方法都继承过来。

 */
class Cat extends Animal{
    public void catchMouse() {
        System.out.println(name + "正在抓老鼠");
    }
}

public class Test {

    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.name = "旺财";
        dog.age = 10;
        dog.barks();
        dog.eat();

    }
}